Skip to content

OpenACC port of halo exchanges #1355

Merged
mgduda merged 2 commits intoMPAS-Dev:developfrom
abishekg7:framework/acc_halo_exch
Mar 20, 2026
Merged

OpenACC port of halo exchanges #1355
mgduda merged 2 commits intoMPAS-Dev:developfrom
abishekg7:framework/acc_halo_exch

Conversation

@abishekg7
Copy link
Copy Markdown
Collaborator

@abishekg7 abishekg7 commented Aug 7, 2025

This PR enables execution of halo exchanges on GPUs via OpenACC directives, when the MPAS atmosphere core has been built with an appropriate GPU-aware MPI library. This PR builds on the OpenACC memory consolidation introduced in #1315.

Module mpas_halo is modified in the following ways to enable GPU-aware halo exchanges:

  • In the call to mpas_halo_exch_group_complete, OpenACC directives copy to device all the relevant fields and metadata that are required for the packing and unpacking loops later.
  • OpenACC directives are introduced around the packing and unpacking loops to perform the field to/from send/recv buffer operations on the device. The attach clauses introduced to the parallel constructs ensures that the device pointers are attached to the device targets at the start of the parallel region and detached at the end of the region.
  • The actual MPI_Isend and MPI_Irecv operations use GPU-aware MPI, by wrapping these calls within
!$acc host_data use_device(pointer_to_buffer)

!$acc end host_data

In addition, this PR introduces a new namelist option under the development group, config_gpu_aware_mpi. When set to true, it switches on GPU-direct halo exchanges. The default setting is false, in which halo exchanges occur on the host, which necessitates host<->device data transfers around the halo exchanges as necessary.

Note: This feature is not available to use when config_halo_exch_method is set to 'mpas_dmpar'

@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch 2 times, most recently from 56ed028 to a8fda92 Compare August 15, 2025 01:07
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from d0c1431 to 1e08917 Compare October 13, 2025 22:50
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from 1e08917 to eff87cf Compare February 27, 2026 06:04
@abishekg7 abishekg7 marked this pull request as ready for review February 27, 2026 06:06
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from eff87cf to 3d2c334 Compare March 4, 2026 20:02
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from 3d2c334 to 5486740 Compare March 13, 2026 20:53
@mgduda mgduda self-requested a review March 14, 2026 01:04
@abishekg7 abishekg7 changed the title [Draft] OpenACC port of halo exchanges OpenACC port of halo exchanges Mar 17, 2026
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from 5486740 to 6ce8e33 Compare March 17, 2026 17:29
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from 6ce8e33 to 2ae3105 Compare March 18, 2026 06:03
@mgduda mgduda self-requested a review March 18, 2026 23:49
@mgduda mgduda self-requested a review March 19, 2026 15:27
G. Dylan Dickerson and others added 2 commits March 19, 2026 16:13
This commit enables execution of halo exchanges on GPUs via OpenACC directives,
if the MPAS atmosphere core has been built with an appropriate GPU-aware MPI
distribution.

Module mpas_halo is modified in the following ways to enable GPU-aware halo
exchanges:

- In the call to mpas_halo_exch_group_complete, OpenACC directives copy to
  device all the relevant fields and metadata that are required for the
  packing and unpacking loops later.
- OpenACC directives are introduced around the packing and unpacking loops to
  perform the field to/from send/recv buffer operations on the device. The
  attach clauses introduced to the parallel constructs ensures that the device
  pointers are attached to the device targets at the start of the parallel
  region and detached at the end of the region.
- The actual MPI_Isend and MPI_Irecv operations use GPU-aware MPI, by wrapping
  these calls within !$acc host_data constructs.

Note: This commit introduces temporary host-device data movements in the
atm_core_init routine around the two calls to exchange_halo_group. This is
required just for this commit as all halo-exchanges occur on the device and
fields not yet present on the device must be copied over to it before the halo
exchanges and back to host after it. These copies will be removed in subsequent
commits.
Introducing a new namelist option under development, config_gpu_aware_mpi,
which will control whether the MPAS runs on GPUs will use GPU-aware MPI or
perform a device<->host update of variables around the call to a purely
CPU-based halo exchange.

Note: This feature is not available to use when config_halo_exch_method is set
to 'mpas_dmpar'
@abishekg7 abishekg7 force-pushed the framework/acc_halo_exch branch from d52ce31 to b0ce630 Compare March 19, 2026 22:40
@mgduda mgduda added Atmosphere Framework OpenACC Work related to OpenACC acceleration of code labels Mar 20, 2026
@mgduda mgduda merged commit 669a7ed into MPAS-Dev:develop Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Atmosphere Framework OpenACC Work related to OpenACC acceleration of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants